package test;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class read {
//    public static void main(String[] args) {
//        read r=new read();
//        try {
//            /*ArrayList<Title> titles = r.AdTi1();
//            String s = titles.toString();*/
//
//            ArrayList<Student> students = r.AdTi2();
//            String s = students.toString();
//            System.out.println(s);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }


    public ArrayList<Title> AdTi1() throws IOException {
        String path="C:\\Users\\Sssller\\Desktop\\ada.txt";
        Reader reader=null;
        BufferedReader bf=null;
        ArrayList<Title> title=new ArrayList<>();
        try {
            reader=new FileReader(path);
            bf=new BufferedReader(reader);
            String i;
            while ((i= bf.readLine()) !=null){
                title.add(new Title(i));
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (bf!=null)bf.close();
        }
        return title;
    }

    public ArrayList<Student> AdTi2() throws IOException {
        String path="C:\\Users\\Sssller\\Desktop\\StudentName.txt";
        Reader reader=null;
        BufferedReader bf=null;
        ArrayList<Student> students=new ArrayList<>();
        try {
            reader=new FileReader(path);
            bf=new BufferedReader(reader);
            String i;
            while ((i= bf.readLine()) !=null){
                students.add(new Student(i));
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (bf!=null)bf.close();
        }
        return students;
    }
}
